import { useUserStore } from "@/store/user";

const userStore = useUserStore();
export const EVENT_KEY = "CHANGE_USER";

function createUserEvent() {
  return new CustomEvent(EVENT_KEY, {
    detail: userStore.userInfo,
  });
}

//主应用派发用户信息事件与子应用通信
export function dispatchUserEvent() {
  const event = createUserEvent();
  window.dispatchEvent(event);
}
